//
//  YJImmediatelygrabView.m
//  SnackCourier
//
//  Created by qianfeng01 on 15/7/19.
//  Copyright (c) 2015年 qianfeng01. All rights reserved.
//

#import "YJImmediatelygrabView.h"
#import "UIImageView+WebCache.h"

@interface YJImmediatelygrabView  ()

@property (nonatomic,weak) id target;
@property (nonatomic,assign) SEL action;

@end


@implementation YJImmediatelygrabView
//增加一个点击事件
-(void)addTarget:(id)target action:(SEL)action{
    self.target =target;
    self.action =action;
}
//手指离开当前视图的时候
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    //忽略SEL 产生的警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
    if ([self.target respondsToSelector:self.action]) {
        [self.target performSelector:self.action withObject:self];
    }
#pragma clang diagnostic pop
}

-(void)showDataWithModel:(YJSalesListModel *)model{
    self.titleLabel.text =model.title;
    self.priceStrLabel.text =[NSString stringWithFormat:@"￥%@",model.priceStr];
    self.originalLabel.text =[NSString stringWithFormat:@"￥%@",model.originalPriceStr];
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.imgUrl]];
    UIView *view =[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.originalLabel.frame.size.width, 2)];
    view.center =self.originalLabel.center;
    view.backgroundColor =[UIColor grayColor];
    
    [self addSubview:view];

}


@end
